package common.interfaces;

import java.sql.SQLException;
import java.util.Collection;

import msg.EventMessage;
import registration.Consensus;

import common.exceptions.InvalidEventException;

/**
 * Manages the persistent of {@link Consensus} objects
 * 
 * @author Gal Lalouche
 */
public interface IConsensusManager extends IDAL<Consensus, Long> {
	/**
	 * Persists the consensus
	 * 
	 * @param con The consensus to persist
	 * @throws InvalidEventException If {@code con.getEvent()} is an invalid event
	 * @throws SQLException
	 */
	void persist(Consensus con) throws InvalidEventException, SQLException;

	/**
	 * Gets all the consensus that belong to an event
	 * 
	 * @param event The event
	 * @return all the consensus that belong to an event
	 * @throws InvalidEventException If the event is invalid
	 * @throws SQLException
	 */
	Collection<Consensus> getAllEventConsensuses(EventMessage event) throws InvalidEventException,
			SQLException;

	/**
	 * @return the last ID used
	 * @throws SQLException
	 */
	long getLastId() throws SQLException;
}
